package org.atguigu.spring6.iocxml.di;

public class Book {
    private String bname;
    private String bauthor;

    public void setOthers(String others) {
        this.others = others;
    }

    private String others;
    public Book() {
    }

    //构造器
    public Book(String bname, String bauthor) {
        System.out.println("有参数构造 book constructor");
        this.bname = bname;
        this.bauthor = bauthor;
    }
    //生成set方法
    public void setBname(String bname) {
        this.bname = bname;
    }

    public void setBauthor(String bauthor) {
        this.bauthor = bauthor;
    }

    public void testDemo() {
        System.out.println("book name:" + bname + " book author:" + bauthor);
    }

    @Override
    public String toString() {
        return "Book{" +
                "bname='" + bname + '\'' +
                ", bauthor='" + bauthor + '\'' +
                '}' ;
    }

    public static void main(String[] args) {
        Book book = new Book();
        book.setBname("java从入门到放弃");
        book.setBauthor("王二");
        book.testDemo();
        //通过构造器注入
        Book book1 = new Book("java从入门到放弃2","王二2");
        book1.testDemo();
    }
}
